package com.frxuexi.mdm2205.demo

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.frxuexi.mdm2205.R
import java.text.SimpleDateFormat

data class Stu(
    val name:String,
    val desc:String,
    val img:String,
    val time:String
)

@Preview
@Composable
fun Demo03() {
    val list = mutableListOf<Stu>()
    for (i in 1..20){
        val time = SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(System.currentTimeMillis())
        list.add(Stu("李四"+i,"这是我的个人介绍"+i,
            "https://img1.baidu.com/it/u=4214113141,2036563917&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1729098000&t=0662d2b383091882ccdd43ad060de2a7",
            time))
    }
    
    LazyColumn(modifier = Modifier.padding(10.dp),verticalArrangement=Arrangement.spacedBy(10.dp), content = {
        items(list){
            Row {
                AsyncImage(model = it.img, contentDescription = "",
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .size(80.dp)
                        .clip(CircleShape))
                Spacer(modifier = Modifier.width(10.dp))
                Column (Modifier.height(80.dp), verticalArrangement = Arrangement.SpaceAround){
                    Text(text = it.name)
                    Text(text = it.time)
                }
            }
            Text(text = it.desc)
        }
    })
    /*LazyRow(modifier = Modifier.padding(10.dp), horizontalArrangement =Arrangement.spacedBy(10.dp), content = {
        items(list){
            Row {
                AsyncImage(model = it.img, contentDescription = "",
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .size(80.dp)
                        .clip(CircleShape))
                Spacer(modifier = Modifier.width(10.dp))
                Column (Modifier.height(80.dp), verticalArrangement = Arrangement.SpaceAround){
                    Text(text = it.name)
                    Text(text = it.desc)
                }
            }
        }
    })*/


    /*LazyVerticalGrid(columns = GridCells.Fixed(2), modifier = Modifier.padding(10.dp),verticalArrangement=Arrangement.spacedBy(10.dp), content = {
        items(list){
            Row {
                AsyncImage(model = it.img, contentDescription = "",
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .size(80.dp)
                        .clip(CircleShape))
                Spacer(modifier = Modifier.width(10.dp))
                Column (Modifier.height(80.dp), verticalArrangement = Arrangement.SpaceAround){
                    Text(text = it.name)
                    Text(text = it.desc)
                }
            }
        }
    })*/
    /*LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Fixed(2), modifier = Modifier.padding(10.dp),verticalItemSpacing=10.dp, content = {
        items(list){
            Row {
                AsyncImage(model = it.img, contentDescription = "",
                    contentScale = ContentScale.Crop,
                    modifier = Modifier
                        .size(80.dp)
                        .clip(CircleShape))
                Spacer(modifier = Modifier.width(10.dp))
                Column (Modifier.height(80.dp), verticalArrangement = Arrangement.SpaceAround){
                    Text(text = it.name)
                    Text(text = it.desc)
                }
            }
        }
    })*/

}